import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:get/state_manager.dart';
import 'package:inspiration_f/utils/size.dart';

import 'home_manager.dart';

class HomeController extends GetxController {
  // 管理动画的model  ---- 需要整个对象的引用变才行，里面的值变化不行。想收到通知的话，需要重新初始化
  var animationModel = HomeAnimationModel().obs;
}

// 管理动画的model
class HomeAnimationModel {
  double myOpacity = 0.0; // 完全透明
  double colorWidth = 0; // 颜色选择view的宽度
  int durationTime = 240;
  double top = HomeManager.instance.startTop; // 默认top的位置
  double contentHeight = homeItemHeight; // 默认内容高度
  double contentOpacity = 0.3; // 内容的透明度
  Curve curve = Curves.linear; // 动画类型

  // 列表状态下默认数据
  initAnimationModel() {
    durationTime = 0;
    myOpacity = 0.0;
    colorWidth = 0;
    contentHeight = homeItemHeight;
    contentOpacity = 0.2; // 内容透明度
    // curve = Curves.easeInOut;
    top = HomeManager.instance.startTop;
  }

  // 列表状态下默认数据
  smallAnimationModel() {
    durationTime = 240;
    myOpacity = 0.0;
    colorWidth = 0;
    contentHeight = homeItemHeight;
    contentOpacity = 0.5; // 内容透明度
    // curve = Curves.easeInOut;
    top = HomeManager.instance.startTop;
  }

  // 弹出状态下默认数据
  bigAnimationModel() {
    durationTime = 240;
    myOpacity = 0.6; // 背景蒙层的透明度
    colorWidth = 28;
    contentHeight = 230;
    contentOpacity = 1.0; // 内容透明度
    // curve = Curves.easeInOut;
    top = 110; // 弹出后的top位置
  }
}
